const file = require('fs');
/* const path = require('path');
path.join('a','b')路径连接a/b
path.basename(‘a/b/c.txt')获取路径中的文件名c.txt
也可以path.basename(‘a/b/c.txt',".txt")可以获得文件名c不加扩展名
path.extname(‘a/b/c.txt')获取扩展txt
 */

file.readFile("/scoreData.txt", function (error, data) {
  if (error) {
    console.log('文件读取失败', error);
  } else {
    let newdata = data.toString();
    console.log(newdata);
    let names = newdata.replace(/=/g, ":");
    let newWrite = names.split(' ').join('\n')
    console.log(newWrite);
    file.writeFile("./scoreNew.txt", newWrite, function (error) {
      if (error) {
        console.log('文件写入失败', error);
      }
    })
  }
})